package com.example.controller.stock;

import com.example.pojo.stock.Product_import;
import com.example.pojo.stock.Product_online;
import com.example.service.commodity.ImportService;
import com.example.service.commodity.OnlineService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.ArrayList;
import java.util.List;

/**
 * com.example.controller.stock
 *
 * @author foam
 * create 2020-12-19
 **/
@Controller
@RequestMapping("/online")
public class OnlineController {
    @Autowired
    private OnlineService onlineService;

    @RequestMapping("/queryAll")
    public String queryAll(Model model) {
        List<Product_online> product_onlinesList = onlineService.queryAll();
        System.out.println(product_onlinesList);
        model.addAttribute("onlineList", product_onlinesList);
        return "/stock/upRecord";
    }

    @RequestMapping("/queryOnlineByDate")
    public String queryOnlineByDate(@RequestParam("date") String date, Model model) {
        List<Product_online> product_onlineList = new ArrayList<>();
        Product_online product_online = onlineService.queryByDate(date);
        System.out.println("-----------------");
        System.out.println(product_online);
        product_onlineList.add(product_online);
        model.addAttribute("onlineList", product_onlineList);
        return "/stock/upRecord";
    }

}
